package uuid;

import java.util.Arrays;
import java.util.List;
import java.util.UUID;

public class UUIDDemo {

    //得到32位的uuid字符串
    public static String getUUID32(){
        return UUID.randomUUID().toString().replace("-", "").toLowerCase();
    }
    //得到指定数量的UUID，以数组的形式返回
    public static String[] getUUID(int num){
        if( num <= 0)
            return null;
        String[] uuidArr = new String[num];
        for (int i = 0; i < uuidArr.length; i++) {
            uuidArr[i] = getUUID32();
        }
        return uuidArr;
    }
    public static void main(String[] args) {
        System.out.println("-------------得到32位的uuid字符串------------");
        System.out.println(getUUID32());
        System.out.println("----------得到指定数量的UUID，以数组的形式返回--------");
        String[] ids = getUUID(10);
        List<String> list = Arrays.asList(ids);
        list.forEach(System.out::println);
    }
}
